<!DOCTYPE html>
<html style="background-color: #F1F4FB">

<head>
    <meta charset="utf-8">
    <title>书著台账页面</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        overflow-y: auto;
        width: 100%;
        left: 16%;
        top: 144px;
    }
    .layui-table-cell {
        text-align: center;
        font-size:14px;
        padding:0 5px;
        height:auto;
        overflow:visible;
        text-overflow:inherit;
        white-space:normal;
        word-break: break-all;
    }
    .layui-laypage-limits select {
        width: 70px;
    }
</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container" style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">
<#--    <div class="layui-row">-->
<#--        <div class="layui-col-md3 layui-col-md-offset9">-->
<#--            <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">-->
<#--            <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">-->
<#--        </div>-->
<#--    </div>-->
    <div class="layui-row">
        <table id="booktable" layui-filter="booktable">

        </table>
    </div>

    <#--	<div class="Right fr mt10">-->
    <#--		<div class="layui-row" style="background-color: #e0e0e0;padding:20px 1%;margin-top:30px;border-radius: 5px">-->
    <#--			<div class="layui-col-md2">-->
    <#--				<span>计划类别:</span>-->

    <#--			</div>-->
    <#--			<div class="layui-col-md2" style="width: 26%">-->
    <#--				<span style="display: inline-block;width:27%">获取时间:</span>-->
    <#--				<input id="hp_time_begin" type="text"  style="display: inline-block;width:35%" value="2021-05-01">-->
    <#--				<span>至</span>-->
    <#--				<input id="hp_time_end" type="text"  style="display: inline-block;width:35%"  value="2021-05-02">-->
    <#--			</div>-->
    <#--		</div>-->
    <#--	</div>-->
</div>
<div style="height: 50px"></div>
<#--	<!--右侧内容&ndash;&gt;-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<#--<script type="text/html" id="xmjb">-->
<#--	{{# if(d.flag){ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="update"><i class="layui-icon">&#xe640;</i>编辑</a>-->
<#--	{{# }else{ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="handle"><i class="layui-icon">&#xe640;</i>办理</a>-->
<#--	{{# } }}-->
<#--</script>-->
<script type="text/html" id="fmc">
    <div>
        <p>{{d.obj1[0].data1}}</p>
        <p class="cursor" style="color: dodgerblue" onclick='seeAllMembers(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.obj1)}}&apos;)'>查看全部发明人</p>
    </div>
</script>
<script type="text/html" id="nfje">
    <div>
        <p>{{d.obj2[0].data2}}</p>
    </div>
</script>
<script type="text/html" id="nfjfsj">
    <div>
        <p>{{d.obj2[0].data3}}</p>
    </div>
</script>
<script type="text/html" id="nfndkd">
    <div>
        <p>{{d.obj2[0].data4}}</p>
    </div>
</script>
<script type="text/html" id="nfjbr">
    <div>
        <p>{{d.obj2[0].data5}}</p>
    </div>
</script>
<script type="text/html" id="nfqbnf">
    <div>
        <p class="cursor" style="color: dodgerblue" onclick='seeAllNfs(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.obj2)}}&apos;)'>全部年费</p>
    </div>
</script>
<script type="text/javascript">
    var table,tableIns,laydate,form,layer;
    layui.use(['laydate','table','form','layer'], function () {
        laydate = layui.laydate;
        table = layui.table;
        form = layui.form;
        layer = layui.layer;
        initTable();

    });

    function setSecondHeadForZhuBian(secondHead,fuZhuBianCount,a,bianWeiCount){
        var aa = a * 1;
        if(aa == 0){
            secondHead[secondHead.length] = {title: '副主编', width: '15%',templet:function(d){
                    var aObj = d.obj1[aa*1];
                    if(aObj && aObj.data1){
                        return '<p>'+aObj.data1+'</p>'
                    }else{
                        return '<p></p>'
                    }

                }}
        }else{
            secondHead[secondHead.length] = {title: '副主编'+(aa*1+1), width: '15%',templet:function(d){
                    var aObj = d.obj1[aa*1];
                    if(aObj && aObj.data1){
                        return '<p>'+aObj.data1+'</p>'
                    }else{
                        return '<p></p>'
                    }

                }}
        }
        if(aa < fuZhuBianCount-1){
            var newIndex = (aa*1) +1;
            setSecondHeadForZhuBian(secondHead,fuZhuBianCount,newIndex,bianWeiCount);
        }else{
            setSecondHeadFormBianWei(secondHead,bianWeiCount,0);
        }
    }

    function setSecondHeadFormBianWei(secondHead,bianWeiCount,b){
        var bb = b * 1;
        if(bb == 0){
            secondHead[secondHead.length] = {title: '编委', width: '15%',templet:function(d){
                    var aObj = d.obj2[bb*1];
                    if(aObj && aObj.data1){
                        return '<p>'+aObj.data1+'</p>'
                    }else{
                        return '<p></p>'
                    }

                }}
        }else{
            secondHead[secondHead.length] = {title: '编委'+(bb*1+1), width: '15%',templet:function(d){
                    var aObj = d.obj2[bb*1];
                    if(aObj && aObj.data1){
                        return '<p>'+aObj.data1+'</p>'
                    }else{
                        return '<p></p>'
                    }

                }}
        }
        if(bb < bianWeiCount-1){
            var newIndex = (bb*1) + 1;
            setSecondHeadFormBianWei(secondHead,bianWeiCount,newIndex);
        }
    }

    function initTable(){
        var jsonDataStr = localStorage.getItem("count-detail-filter-sz");
        var jsonData = JSON.parse(jsonDataStr);
        console.log("书著数字详情页,jsonData:");
        console.log(jsonData);
        var fuZhuBianCount = 0;
        var bianWeiCount = 0;
        //根据条件获取副主编  编委集合:
        $.ajax({
            url: '/search/decision/getZhuBianAndBianWeiCount',
            data: jsonData,
            type: 'get',
            dataType: 'json',
            success: function(res){
                console.log(res);
                if(res.flag){
                    fuZhuBianCount = res.data.fuZhuBianCount*1;
                    if(fuZhuBianCount == 0){
                        fuZhuBianCount == 1;
                    }
                    bianWeiCount = res.data.bianWeiCount*1;
                    if(bianWeiCount == 0){
                        bianWeiCount == 1;
                    }
                    var secondHead = [];
                    //二级表头添加副主编

                    if(fuZhuBianCount && fuZhuBianCount*1>0){
                        setSecondHeadForZhuBian(secondHead,fuZhuBianCount,0,bianWeiCount);
                    }
                    //二级表头添加编委
                    // if(bianWeiCount && bianWeiCount*1>0){
                    // 	setSecondHeadFormBianWei(secondHead,bianWeiCount,0);
                    // }
                    var fuZhuBianHeadFirst = {};
                    if(fuZhuBianCount > 1){
                        fuZhuBianHeadFirst = {align: 'center', title: '副主编',colspan: fuZhuBianCount};
                    }else{
                        fuZhuBianHeadFirst = {align: 'center', title: '副主编',colspan: fuZhuBianCount,colGroup: true};
                    }
                    var bianWeiHeadFirst = {};
                    if(bianWeiCount > 1){
                        bianWeiHeadFirst = {align: 'center', title: '编委',colspan: bianWeiCount}
                    }else[
                        bianWeiHeadFirst = {align: 'center', title: '编委',colspan: bianWeiCount,colGroup: true}
                    ]

                    //方法级渲染
                    tableIns = table.render({
                        id: 'booktable',
                        elem: '#booktable',
                        url: '/search/decision/form/book/110006',
                        height: "full",
                        // toolbar: '#toolbarDemo',
                        where: jsonData,
                        page: true,
                        cols: [[
                            {
                                title: '序号', width: '8%', rowspan: 2, templet: function (res) {
                                    return res.LAY_INDEX;
                                }
                            },
                            {field: 'spfF1', title: '书著名称', width: '15%', rowspan: 2},
                            {field: 'spfF2', title: '出版社名称', width: '15%', rowspan: 2},
                            {field: 'spfF3', title: 'ISBN号', width: '15%', rowspan: 2},
                            {field: 'spfF4', title: '主编', width: '15%', rowspan: 2},
                            fuZhuBianHeadFirst,
                            bianWeiHeadFirst,
                            {field: 'spfF5', title: '版次时间', width: '15%', rowspan: 2},
                            {field: 'spfF6', title: '版次数', width: '10%', rowspan: 2},
                            {field: 'spfF7', title: '开本', width: '10%', rowspan: 2},
                            {field: 'spfF8', title: '字数', width: '10%', rowspan: 2},
                            {field: 'spfF9', title: '定价', width: '10%', rowspan: 2},
                            {field: 'spfF5', title: '书著word', width: '10%', rowspan: 2,templet: function(d){
                                    var returnStr = '';
                                    if(d.fileList1 && d.fileList1.length > 0){
                                        for(var a=0;a<d.fileList1.length;a++){
                                            returnStr = returnStr + '<p>'+d.fileList1[a].fileName+'</p>';
                                        }
                                        return returnStr;
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'spfF5', title: '扫描件pdf', width: '10%', rowspan: 2,templet: function(d){
                                    var returnStr = '';
                                    if(d.fileList2 && d.fileList2.length > 0){
                                        for(var a=0;a<d.fileList2.length;a++){
                                            returnStr = returnStr + '<p>'+d.fileList2[a].fileName+'</p>';
                                        }
                                        return returnStr;
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'spfF10', title: '备注', width: '10%', rowspan: 2}
                        ],
                            secondHead]
                        ,
                        done: function (res, currentCount) {

                        }
                    });


                }
            }
        })

    }

    function getQuaryData(){
        //书著名称
        var szmcSelect = $('#sz_name').val();

        //主编:
        var zbmcSelect = $('#zb_name').val();

        //版次时间开始日期
        var bc_startSelect= $('#bc_date_start').val();

        //版次时间结束日期
        var bc_endSelect= $('#bc_date_end').val();

        var jsondata = {
            spfF1:szmcSelect,
            spfF4:zbmcSelect,
            obj1:bc_startSelect,
            obj2:bc_endSelect
        };
        return jsondata;
    }



    function query() {
        initTable();
    }

    function resetQuery(){
        $('#lw_name').val('');
        $('#qk_type_select').val('000');
        $('#qk_name').val('');
        $('#jk_date_start').val('');
        $('#jk_date_end').val('000');
        query();
    }

    function getZllx(zllx){
        var zllxListStr = '${zllxListStr}';
        var zllxList = JSON.parse(zllxListStr);
        var returnStr = '';
        if(zllxList && zllxList.length>0){
            for(var a=0;a<zllxList.length;a++){
                if(zllx == zllxList[a].badtCode){
                    returnStr = zllxList[a].badtName;
                }
            }
        }
        return returnStr;
    }

    function getJd(jd){
        var jdListStr = '${jdListStr}';
        var jdList = JSON.parse(jdListStr);
        var returnStr = '';
        if(jdList && jdList.length>0){
            for(var a=0;a<jdList.length;a++){
                if(jd == jdList[a].badtCode){
                    returnStr = jdList[a].badtName;
                }
            }
        }
        return returnStr;
    }

    function viewTable(){
        var jsondata = getQuaryData();
        $.ajax({
            url: '/search/decision/form/book/viewTable/110006',
            data: jsondata,
            type: 'get',
            dataType: 'json',
            success: function(res){
                if(res.flag){
                    if(res.data){
                        var w = ($(window).width()*0.8);
                        var h = ($(window).height()*0.8);
                        POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                    }
                }
            }
        })
    }

    function exportTable(){
        var para = '';
        //书著名称
        var szmcSelect = $('#sz_name').val();
        if(szmcSelect){
            para = para+'&spfF1='+szmcSelect;
        }
        //主编:
        var zbmcSelect = $('#zb_name').val();
        if(zbmcSelect){
            para = para+'&spfF4='+zbmcSelect;
        }
        //版次时间开始日期
        var bc_startSelect= $('#bc_date_start').val();
        if(bc_startSelect){
            para = para+'&obj1='+bc_startSelect;
        }
        //版次时间结束日期
        var bc_endSelect= $('#bc_date_end').val();
        if(bc_endSelect){
            para = para+'&obj2='+bc_endSelect;
        }
        //获取全部数据:
        var url= '/search/decision/form/export/book/110006?a_='+Math.random()+para;
        location.href = url;
    }

    function seeAllMembers(zlmc,fmrListStr){
        var names = [];
        var fmrList = JSON.parse(fmrListStr);
        if(fmrList){
            for(var a=0;a<fmrList.length;a++){
                if(fmrList[a].data1){
                    var aStData = {};
                    aStData.index = a+1;
                    aStData.name = fmrList[a].data1;
                    names[names.length] = aStData;
                }
            }
            // for(var b=0;b<20;b++){
            // 	var testData = {};
            // 	testData.index = names.length+1;
            // 	testData.name = '测试';
            // 	names[names.length] = testData;
            // }
            localStorage.setItem("form-project-name",zlmc);
            localStorage.setItem("form-project-members",JSON.stringify(names));
            localStorage.setItem("form-project-field-name",'发明人');
            var w = ($(window).width()*0.8);
            var h = ($(window).height()*0.8);
            layer.open({
                type: 2,
                title: false,
                closeBtn: 1,
                shade: 0.8,
                area: [w+'px',h+'px'],
                content: '/search/decision/showMembers',
                success: function(layero, index){

                },
                end: function () {
                    localStorage.removeItem("form-project-name");
                    localStorage.removeItem("form-project-members");
                    localStorage.removeItem("form-project-field-name");
                }
            })
        }
    }


    function seeAllNfs(zlmc,obj2){
        var cols = [];
        var innerCol = [];

        var field1 = {title: '序号', width: '15%', templet: '#index'};
        innerCol[innerCol.length] = field1;
        var field2 =  {field: 'data2',title: '金额', width: '15%'};
        innerCol[innerCol.length] = field2;
        var field3 =  {field: 'data3',title: '缴费时间', width: '30%'};
        innerCol[innerCol.length] = field3;
        var field4 =  {field: 'data4',title: '年费跨度', width: '20%'};
        innerCol[innerCol.length] = field4;
        var field5 =  {field: 'data5',title: '经办人', width: '20%'};
        innerCol[innerCol.length] = field5;
        cols[cols.length] = innerCol;
        localStorage.setItem('form-smart-table-type','colsAndDatas');
        localStorage.setItem("form-project-name",zlmc);
        localStorage.setItem("colsAndDatas-cols",JSON.stringify(cols));
        localStorage.setItem("colsAndDatas-datas",obj2);
        var w = ($(window).width()*0.8);
        var h = ($(window).height()*0.8);
        layer.open({
            type: 2,
            title: false,
            closeBtn: 1,
            shade: 0.8,
            area: [w+'px',h+'px'],
            content: '/search/decision/showMembers',
            success: function(layero, index){

            },
            end: function () {
                localStorage.removeItem("form-project-name");
                localStorage.removeItem("form-project-members");
                localStorage.removeItem("form-project-field-name");
            }
        })
    }



</script>
</body>

</html>